from rest_framework import serializers
from goods.models import GoodsChannel, GoodsCategory, GoodsChannelGroup


# 1.channel序列化器
class ChannelViewSetSerializer(serializers.ModelSerializer):
    # 1.重写group
    group = serializers.StringRelatedField(read_only=True)
    group_id = serializers.IntegerField()

    # 2.重写category
    category = serializers.StringRelatedField(read_only=True)
    category_id = serializers.IntegerField()

    class Meta:
        model = GoodsChannel
        fields = "__all__"


# 2.channel type序列化器
class ChannelTypesSerializer(serializers.ModelSerializer):
    class Meta:
        model = GoodsChannelGroup
        fields = "__all__"


# category序列化器
class CategoryViewSetSerializer(serializers.ModelSerializer):
    class Meta:
        model = GoodsCategory
        fields = "__all__"








